package com.tcu.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tcu.order.entity.OrderVideo;
import com.tcu.order.mapper.OrderVideoMapper;
import com.tcu.order.service.IOrderVideoService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderVideoServiceImpl extends ServiceImpl<OrderVideoMapper, OrderVideo> implements IOrderVideoService {
    @Override
    public List<OrderVideo> getVideosByOrderId(String orderId) {
        QueryWrapper<OrderVideo> wrapper = new QueryWrapper<>();
        wrapper.eq("order_id",orderId);
        List<OrderVideo> orderVideos = baseMapper.selectList(wrapper);
        return orderVideos;
    }

    @Override
    public Integer deleteVideosByOrderId(String orderId) {
        QueryWrapper<OrderVideo> wrapper = new QueryWrapper<>();
        wrapper.eq("order_id",orderId);
        int delete = baseMapper.delete(wrapper);
        return delete;
    }

    @Override
    public List<OrderVideo> getSomeVideos(String orderId, Integer isUser) {
        QueryWrapper<OrderVideo> wrapper = new QueryWrapper<>();
        wrapper.eq("order_id",orderId)
                .eq("is_user",isUser);
        List<OrderVideo> orderVideos = baseMapper.selectList(wrapper);
        return orderVideos;
    }
}
